home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Harvest C 1.3 / Source Code / Warnings.c < prev   
Encoding:
C/C++ Source or Header  |  1992-06-15  |  6.7 KB  |  255 lines  |  [TEXT/ALFA]

  1. /*
  2.     Harvest C
  3.     Copyright 1992 Eric W. Sink.  All rights reserved.
  4.     
  5.     This file is part of Harvest C.
  6.     
  7.     Harvest C is free software; you can redistribute it and/or modify
  8.     it under the terms of the GNU Generic Public License as published by
  9.     the Free Software Foundation; either version 2, or (at your option)
  10.     any later version.
  11.     
  12.     Harvest C is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.     
  17.     You should have received a copy of the GNU General Public License
  18.     along with Harvest C; see the file COPYING.  If not, write to
  19.     the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  20.     
  21.     Harvest C is not in any way a product of the Free Software Foundation.
  22.     Harvest C is not GNU software.
  23.     Harvest C is not public domain.
  24.  
  25.     This file may have other copyrights which are applicable as well.
  26.  
  27. */
  28.  
  29. /*
  30.  * Harvest C
  31.  * 
  32.  * Copyright 1991 Eric W. Sink   All rights reserved.
  33.  * 
  34.  * This file contains routines for handling compiler warnings.
  35.  * 
  36.  * 
  37.  */
  38.  
  39.  
  40. #include "conditcomp.h"
  41. #include <stdio.h>
  42. #include <string.h>
  43.  
  44. #include "structs.h"
  45.  
  46. #pragma segment Warnings
  47.  
  48. void
  49. PrintWarningText(enum Ecc_Warnings whichone)
  50. {
  51.     switch (whichone) {
  52.     case WARN_emptystatement:
  53.     UserMesg("Empty expression stmt");
  54.     break;
  55.     case WARN_multicharconstant:
  56.     UserMesg("Multi-character constant");
  57.     break;
  58.     case WARN_redundantcast:
  59.     UserMesg("Redundant cast");
  60.     break;
  61.     case WARN_floateqcompare:
  62.     UserMesg("Equivalence test of floating type");
  63.     break;
  64.     case WARN_discardfuncresult:
  65.     UserMesg("Discarded function result");
  66.     break;
  67.     case WARN_assignif:
  68.     UserMesg("Assignment as if conditional");
  69.     break;
  70.     case WARN_nonvoidreturn:
  71.     UserMesg("Non-void function has no return statement");
  72.     break;
  73.     case WARN_constantif:
  74.     UserMesg("Constant expression as if condition");
  75.     break;
  76.     case WARN_comparepointerint:
  77.     UserMesg("Comparison of pointer and integer");
  78.     break;
  79.     case WARN_pointernonequivassign:
  80.     UserMesg("Assignment of nonequivalent type to a pointer");
  81.     break;
  82.     case WARN_pointernonequivreturn:
  83.     UserMesg("Return of nonequivalent type to a pointer");
  84.     break;
  85.     case WARN_pointernonequivarg:
  86.     UserMesg("Pass of nonequivalent type to a pointer");
  87.     break;
  88.     case WARN_constantswitch:
  89.     UserMesg("Constant expression as switch condition");
  90.     break;
  91.     case WARN_constantwhile:
  92.     UserMesg("Constant expression as while loop condition");
  93.     break;
  94.     case WARN_constantdowhile:
  95.     UserMesg("Constant expression as do-while loop condition");
  96.     break;
  97.     case WARN_constantfor:
  98.     UserMesg("Constant expression as for loop condition");
  99.     break;
  100.     case WARN_nonintegralswitch:
  101.     UserMesg("Switch expression not of integral type.");
  102.     break;
  103.     case WARN_novolatile:
  104.     UserMesg("Volatile is not handled by this compiler");
  105.     break;
  106.     /* Missing warnings here AVAILABLE1 */
  107.     case WARN_unusedvariable:
  108.     UserMesg("Unused variable: ");
  109.     break;
  110.     case WARN_deadcode:
  111.     UserMesg("Dead code");
  112.     break;
  113.     case WARN_implicitdecl:
  114.     UserMesg("Implicit decl : ");
  115.     break;
  116.     case WARN_preprocredef:
  117.     UserMesg("Re#definition : ");
  118.     break;
  119.     case WARN_nestedcomment:
  120.     UserMesg("Possible nested comment");
  121.     break;
  122.     /* Missing warnings here AVAILABLE2 */
  123.     case WARN_goto:
  124.     UserMesg("goto statement found");
  125.     break;
  126.     case WARN_multireturn:
  127.     UserMesg("Multiple function returns");
  128.     break;
  129.     case WARN_emptycompound:
  130.     UserMesg("Empty compound statement");
  131.     break;
  132.     case WARN_missingreturntype:
  133.     UserMesg("Missing function return type - default to int");
  134.     break;
  135.     case WARN_trigraphs:
  136.     UserMesg("Trigraph found");
  137.     break;
  138.     /* Missing warnings here AVAILABLE3 */
  139.     case WARN_pascal:
  140.     UserMesg("pascal keyword found");
  141.     break;
  142.     /* Missing warnings here AVAILABLE4 */
  143.     case WARN_semiafterfunction:
  144.     UserMesg("Semicolon after function body");
  145.     break;
  146.     default:
  147.     UserMesg("Unimplemented warning");
  148.     break;
  149.     }
  150. }
  151.  
  152. void
  153. GetWarningText(char *buf, int whichone)
  154. {
  155.     switch (whichone) {
  156.     case WARN_emptystatement:
  157.     strcat(buf,"Empty expression stmt");
  158.     break;
  159.     case WARN_multicharconstant:
  160.     strcat(buf,"Multi-character constant");
  161.     break;
  162.     case WARN_redundantcast:
  163.     strcat(buf,"Redundant cast");
  164.     break;
  165.     case WARN_floateqcompare:
  166.     strcat(buf,"Equivalence test of floating type");
  167.     break;
  168.     case WARN_discardfuncresult:
  169.     strcat(buf,"Discarded function result");
  170.     break;
  171.     case WARN_assignif:
  172.     strcat(buf,"Assignment as if conditional");
  173.     break;
  174.     case WARN_nonvoidreturn:
  175.     strcat(buf,"Non-void function has no return statement");
  176.     break;
  177.     case WARN_constantif:
  178.     strcat(buf,"Constant expression as if condition");
  179.     break;
  180.     case WARN_comparepointerint:
  181.     strcat(buf,"Comparison of pointer and integer");
  182.     break;
  183.     case WARN_pointernonequivassign:
  184.     strcat(buf,"Assignment of nonequivalent type to a pointer");
  185.     break;
  186.     case WARN_pointernonequivreturn:
  187.     strcat(buf,"Return of nonequivalent type to a pointer");
  188.     break;
  189.     case WARN_pointernonequivarg:
  190.     strcat(buf,"Pass of nonequivalent type to a pointer");
  191.     break;
  192.     case WARN_constantswitch:
  193.     strcat(buf,"Constant expression as switch condition");
  194.     break;
  195.     case WARN_constantwhile:
  196.     strcat(buf,"Constant expression as while loop condition");
  197.     break;
  198.     case WARN_constantdowhile:
  199.     strcat(buf,"Constant expression as do-while loop condition");
  200.     break;
  201.     case WARN_constantfor:
  202.     strcat(buf,"Constant expression as for loop condition");
  203.     break;
  204.     case WARN_nonintegralswitch:
  205.     strcat(buf,"Switch expression not of integral type.");
  206.     break;
  207.     case WARN_novolatile:
  208.     strcat(buf,"Volatile is not handled by this compiler");
  209.     break;
  210.     /* Missing warnings here AVAILABLE1 */
  211.     case WARN_unusedvariable:
  212.     strcat(buf,"Unused variable: ");
  213.     break;
  214.     case WARN_deadcode:
  215.     strcat(buf,"Dead code");
  216.     break;
  217.     case WARN_implicitdecl:
  218.     strcat(buf,"Implicit decl : ");
  219.     break;
  220.     case WARN_preprocredef:
  221.     strcat(buf,"Re#definition : ");
  222.     break;
  223.     case WARN_nestedcomment:
  224.     strcat(buf,"Possible nested comment");
  225.     break;
  226.     /* Missing warnings here AVAILABLE2 */
  227.     case WARN_goto:
  228.     strcat(buf,"goto statement found");
  229.     break;
  230.     case WARN_multireturn:
  231.     strcat(buf,"Multiple function returns");
  232.     break;
  233.     case WARN_emptycompound:
  234.     strcat(buf,"Empty compound statement");
  235.     break;
  236.     case WARN_missingreturntype:
  237.     strcat(buf,"Missing function return type - default to int");
  238.     break;
  239.     case WARN_trigraphs:
  240.     strcat(buf,"Trigraph found");
  241.     break;
  242.     /* Missing warnings here AVAILABLE3 */
  243.     case WARN_pascal:
  244.     strcat(buf,"pascal keyword found");
  245.     break;
  246.     /* Missing warnings here AVAILABLE4 */
  247.     case WARN_semiafterfunction:
  248.     strcat(buf,"Semicolon after function body");
  249.     break;
  250.     default:
  251.     strcat(buf,"Unimplemented warning");
  252.     break;
  253.     }
  254. }
  255.